package com.aishua.fire.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aishua.fire.entity.aateam.AddAccountAteamInfo;
import com.aishua.fire.jpa.AccountAccountteamDao;
import com.aishua.fire.jpa.entity.AccountAccountteam;
import com.aishua.fire.jpa.entity.AccountAccountteamId;
import com.aishua.fire.mapper.AccountAccountteamMapper;
import com.aishua.fire.service.AccountAteamService;

@Service
public class AccountAteamServiceImpl implements AccountAteamService {

	@Autowired
	private AccountAccountteamDao accountAteamDao;
	
	@Autowired
	private AccountAccountteamMapper accountAccountteamMapper;
	
	@Override
	public void save(AddAccountAteamInfo accountInfo) {
		AccountAccountteam accountAteam = new AccountAccountteam();
		accountAteam.setAccountAccountteamId(new AccountAccountteamId(Long.parseLong(accountInfo.getAccountId()),Long.parseLong(accountInfo.getAccountteamId())));
		accountAteamDao.save(accountAteam);
	}

	@Override
	public void delete(String accountId,String accountAteamId) {
		AccountAccountteamId id = new AccountAccountteamId(Long.parseLong(accountId),Long.parseLong(accountAteamId));
		accountAteamDao.delete(id);
		
	}

	//根据account_id和accountteam_id来查询(验证重复性)
	public Long findByAccoutIdAndAccountteamId(Map<String, Object> pram) {
		Long accountId = accountAccountteamMapper.findByAccoutIdAndAccountteamId(pram);
		return accountId;
	}


}
